package com.example.meterialproject.exts

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.meterialproject.adapter.TransitionAdapter
import com.example.meterialproject.bean.TransitionBean
import com.google.android.material.button.MaterialButton

/**
 *
 * @ClassName: ActivityExt
 * @Author: android 超级兵
 * @CreateDate: 2/10/22$ 3:25 PM$
 * TODO
 */

private var currentTime = 0L
fun <T : Activity> AppCompatActivity.jumpActivity(
    view: View,
    clazz: Class<T>,
    fastRun: Boolean = false, // 是否立即执行
) {
    val currentTimeMillis = System.currentTimeMillis()
    // 避免重复点击
    if (currentTimeMillis - 1_000 >= currentTime || fastRun) {
        startActivity(
            Intent(
                this,
                clazz
            ) title (view.takeView<TextView>()?.text?.toString() ?: "")
        )
        currentTime = currentTimeMillis
    }
}


